// JavaScript Document
	function valbutton_branh(thisform,objname) {
		var objradio = thisform.radioTK;
		var radioLength = objradio.length;
		var id, i;
		if(!radioLength){
			id = objradio.value;		
		}else{
			for(i = 0; i < radioLength; i++){
				if(thisform.radioTK[i].checked){
					id = thisform.radioTK[i].value;
					break;
				}
			}
		}
		//alert(id);
		var name = id.split('-');	
		//alert(name[0]);
		var lblname = objname.split('-');
		var obj1 = window.opener.document.getElementById(lblname[0]);
		var obj2 = window.opener.document.getElementById(lblname[1]);
		if(obj1){
			obj1.value = name[0];
		}
		if(obj2){
			obj2.value = name[1];
		}
		
		window.close();
	}
	
	function add_new(id,idlist){
		var id = document.getElementById(id).value;	
		var id_list = document.getElementById(idlist).value;
		var id_arr = id_list.split('|');
		var string_return='';
		var num=0;
		for(var i in id_arr){
			if (id_arr[i]==id){
				num=1;
				break;
			}
		}
		if(num==0){
			string_return = id;
			document.getElementById(idlist).value = document.getElementById(idlist).value + string_return +"|";
		}
	}
	
	function deleted(id,idlist){
		var i;
		var num=0;
		var id = document.getElementById(id).value;
		var id_list = document.getElementById(idlist).value;
		var id_arr = id_list.split('|');
		if(id_list.replace('|','')==id){
			document.getElementById(idlist).value='';
			num=1;
		}
		if(num==0){
			for(i in id_arr){
				if(id_arr[i]==id){	
					id_list = id_list.replace(id+'|','');
				}
			}
			document.getElementById(idlist).value = id_list;
		}
	}
	
	function selecLoaichitieu(number){
		//alert(789);
		var f_type = document.getElementById("F_TYPE"+number).value;
		
		//alert(f_type);
		
		if(f_type == '1'){
			/*document.getElementById("MACT"+number).disabled = true;
			document.getElementById("add_"+number).disabled = true;
			document.getElementById("delete_"+number).disabled = true;
			document.getElementById("F0"+number).readOnly = false;*/
			document.getElementById('CURORAMT'+number).disabled = false;
			document.getElementById('AMTTYPE'+number).disabled = false;
			
			//document.getElementById('F0'+number).value='';
			document.getElementById('F0'+number).readOnly = true;
			document.getElementById('add_branhcode'+number).disabled = false;
			document.getElementById('delete_branhcode'+number).disabled = false;
			//alert(f_type);
			var radio = document.getElementsByName("GLORAP"+number);
				for (var ii = 0; ii < radio.length; ii++){
					radio[ii].disabled = false;
				}
		}else{
			
			var radioGL = document.getElementsByName("GLORAP"+number);
			radioGL[0].click();
			selectradioGLPH('GL',number);
			//alert('13134');
			//alert(f_type);
			//alert('add_branhcode'+number);
			//document.getElementById('F0'+number).value='';
			document.getElementById('add_branhcode'+number).disabled = true;
			document.getElementById('delete_branhcode'+number).disabled = true;	
			document.getElementById('F0'+number).readOnly = false;
			
			//document.getElementById('CURORAMT'+number).value = '';
			//document.getElementById('AMTTYPE'+number).value = '';
			document.getElementById('CURORAMT'+number).disabled = true;
			document.getElementById('AMTTYPE'+number).disabled = true;
			
			var radio = document.getElementsByName("GLORAP"+number);
			//alert(radio);
			for (var ii = 0; ii < radio.length; ii++){
				radio[ii].disabled = true;
			}
		}
		selectcombo_soduhayphatsinh(number);
	}
	
	function selecLoaichitieu_1_2(number){
		//alert('123');
		var f_type = document.getElementById("F_TYPE"+number).value;
		//alert(f_type);
		
		if(f_type == '1'){
			/*document.getElementById("MACT"+number).disabled = true;
			document.getElementById("add_"+number).disabled = true;
			document.getElementById("delete_"+number).disabled = true;
			document.getElementById("F0"+number).readOnly = false;*/
			document.getElementById('CURORAMT'+number).disabled = false;
			document.getElementById('AMTTYPE'+number).disabled = false;
			//document.getElementById('F0'+number).value='';
			document.getElementById('F0'+number).readOnly = true;
			document.getElementById('ADD_BRANKCODE10').disabled = false;
			document.getElementById('DELETE_BRANKCODE10').disabled = false;
			document.getElementById('ADD_BRANHCODE'+number).disabled = false;
			document.getElementById('DELETE_BRANHCODE'+number).disabled = false;
			
			//alert('1234567');
			var radio = document.getElementsByName("GLORAP"+number);
				for (var ii = 0; ii < radio.length; ii++){
					radio[ii].disabled = false;
				}
		}else{
			
			var radioGL = document.getElementsByName("GLORAP"+number);
			radioGL[0].click();
			selectradioGLPH('GL',number);
			//alert('13134: '+number);
			//alert('123456');
			
			//alert(f_type);
			//document.getElementById('CURORAMT'+number).value = '';
			//document.getElementById('AMTTYPE'+number).value = '';
			document.getElementById('CURORAMT'+number).disabled = true;
			document.getElementById('AMTTYPE'+number).disabled = true;
			document.getElementById('F0'+number).readOnly = false;
			//document.getElementById('F0'+number).value='';
			//alert('ADD_BRANHCODE'+number);
			document.getElementById('ADD_BRANHCODE'+number).disabled = true;
			document.getElementById('DELETE_BRANHCODE'+number).disabled = true;
			document.getElementById('ADD_BRANKCODE10').disabled = true;
			document.getElementById('DELETE_BRANKCODE10').disabled = true;
			//document.getElementById('AMTTYPE'+number).disabled = true;
			/*document.getElementById("MACT"+number).disabled = false;
			document.getElementById("add_"+number).disabled = false;
			document.getElementById("delete_"+number).disabled = false;
			document.getElementById("F0"+number).readOnly = true;*/
			
			//alert('dd: '+number);
			
			var radio = document.getElementsByName("GLORAP"+number);
			//alert(radio);
			for (var ii = 0; ii < radio.length; ii++){
				radio[ii].disabled = true;
			}
		}
		selectcombo_soduhayphatsinh(number);
	}
	
	function selectradioGLPH(type,number){
		//alert(111221);	
		//alert(type+'_'+number);
		 switch (type+'_'+number){
			case "GL_"+number:{ 
				//alert('1111111111');
				//document.getElementById('SBVORBTS'+number).value = '';
				document.getElementById('CURORAMT'+number).value = '';
				document.getElementById('AMTTYPE'+number).value = '';
				
				document.getElementById('CIFTYPE'+number).value = '';
				//alert('22');
				//document.getElementById('TYPE'+number).value = '';
				
				document.getElementById('CURORINT'+number).value = '';
				document.getElementById('FRMTERMCD'+number).value = '';
				document.getElementById('FRMTERM'+number).value = '';
				document.getElementById('TOTERMCD'+number).value = '';
				document.getElementById('TOTERM'+number).value = '';
				
				document.getElementById('FDTYPE'+number).value = '';
				
				document.getElementById('FRMODSTAT'+number).value = '';
				document.getElementById('TOODSTAT'+number).value = '';
				document.getElementById('SECSTATUS'+number).value = '';
				document.getElementById('PPLN'+number).value = '';
				document.getElementById('CLLIST'+number).value = '';
				
				document.getElementById('TRTERM'+number).value = '';
				document.getElementById('FDORLN'+number).value = '';
				document.getElementById('TRPRD'+number).value = '';
				
				document.getElementById('PRDGRP'+number).value = '';
				document.getElementById('PRDCODE'+number).value = '';
				
			}
			case "PH_"+number:{ 
				//alert('2222222222');
				//document.getElementById('SBVORBTS'+number).value = '';
				document.getElementById('CURORAMT'+number).value = '';
				document.getElementById('AMTTYPE'+number).value = '';
				
			}
			default:{
				break;	
			}
		 }
	}
	
	function selectradioclearcontrol(type,number){
		//alert(type+'_'+number);
		 switch (type+'_'+number){
			case "A_"+number:{ 
				/******************** Bat dau GL *************************/
				//document.getElementById('SBVORBTS'+number).value = '';
				//document.getElementById('CURORAMT'+number).value = '';
				//document.getElementById('AMTTYPE'+number).value = '';
				/******************** ket thuc GL *************************/
				
				/******************** Bat dau Phan he *************************/
				/********** DD A_1**************/
				/*document.getElementById('CIFTYPE'+number).value = '';
				document.getElementById('TYPE'+number).value = '';
				document.getElementById('CURORINT'+number).value = '';
				document.getElementById('FRMTERMCD'+number).value = '';
				document.getElementById('FRMTERM'+number).value = '';
				document.getElementById('TOTERMCD'+number).value = '';
				document.getElementById('TOTERM'+number).value = '';*/
				
				/********** FD B_1**************/
				document.getElementById('FDTYPE'+number).value = '';
				
				/********** LN C_1**************/
				document.getElementById('FRMODSTAT'+number).value = '';
				document.getElementById('TOODSTAT'+number).value = '';
				document.getElementById('SECSTATUS'+number).value = '';
				document.getElementById('PPLN'+number).value = '';
				document.getElementById('CLLIST'+number).value = '';
				
				/********** TR D_5**************/
				document.getElementById('TRTERM'+number).value = '';
				document.getElementById('FDORLN'+number).value = '';
				document.getElementById('TRPRD'+number).value = '';
				
				/********** TF E_1**************/
				document.getElementById('PRDGRP'+number).value = '';
				document.getElementById('PRDCODE'+number).value = '';
				break; 
				}
			case "B_"+number:{ 
				/******************** Bat dau GL *************************/
				//document.getElementById('SBVORBTS'+number).value = '';
				//document.getElementById('CURORAMT'+number).value = '';
				//document.getElementById('AMTTYPE'+number).value = '';
				/******************** ket thuc GL *************************/
				
				/******************** Bat dau Phan he *************************/
				/********** DD A_1**************/
				/*document.getElementById('CIFTYPE'+number).value = '';
				document.getElementById('TYPE'+number).value = '';
				document.getElementById('CURORINT'+number).value = '';
				document.getElementById('FRMTERMCD'+number).value = '';
				document.getElementById('FRMTERM'+number).value = '';
				document.getElementById('TOTERMCD'+number).value = '';
				document.getElementById('TOTERM'+number).value = '';*/
				
				/********** FD B_1**************/
				//document.getElementById('FDTYPE'+number).value = '';
				
				/********** LN C_1**************/
				document.getElementById('FRMODSTAT'+number).value = '';
				document.getElementById('TOODSTAT'+number).value = '';
				document.getElementById('SECSTATUS'+number).value = '';
				document.getElementById('PPLN'+number).value = '';
				document.getElementById('CLLIST'+number).value = '';
				
				/********** TR D_5**************/
				document.getElementById('TRTERM'+number).value = '';
				document.getElementById('FDORLN'+number).value = '';
				document.getElementById('TRPRD'+number).value = '';
				
				/********** TF E_1**************/
				document.getElementById('PRDGRP'+number).value = '';
				document.getElementById('PRDCODE'+number).value = '';
				break ;
			}
			case "C_"+number:{ 
				/******************** Bat dau GL *************************/
				//document.getElementById('SBVORBTS'+number).value = '';
				//document.getElementById('CURORAMT'+number).value = '';
				//document.getElementById('AMTTYPE'+number).value = '';
				/******************** ket thuc GL *************************/
				
				/******************** Bat dau Phan he *************************/
				/********** DD A_1**************/
				/*document.getElementById('CIFTYPE'+number).value = '';
				document.getElementById('TYPE'+number).value = '';
				document.getElementById('CURORINT'+number).value = '';
				document.getElementById('FRMTERMCD'+number).value = '';
				document.getElementById('FRMTERM'+number).value = '';
				document.getElementById('TOTERMCD'+number).value = '';
				document.getElementById('TOTERM'+number).value = '';*/
				
				/********** FD B_1**************/
				document.getElementById('FDTYPE'+number).value = '';
				
				/********** LN C_1**************/
				/*document.getElementById('FRMODSTAT'+number).value = '';
				document.getElementById('TOODSTAT'+number).value = '';
				document.getElementById('SECSTATUS'+number).value = '';
				document.getElementById('PPLN'+number).value = '';
				document.getElementById('CLLIST'+number).value = '';*/
				
				/********** TR D_5**************/
				document.getElementById('TRTERM'+number).value = '';
				document.getElementById('FDORLN'+number).value = '';
				document.getElementById('TRPRD'+number).value = '';
				
				/********** TF E_1**************/
				document.getElementById('PRDGRP'+number).value = '';
				document.getElementById('PRDCODE'+number).value = '';
				break ;
			}
			case "D_"+number:{ 
				/******************** Bat dau GL *************************/
				//document.getElementById('SBVORBTS'+number).value = '';
				//document.getElementById('CURORAMT'+number).value = '';
				//document.getElementById('AMTTYPE'+number).value = '';
				/******************** ket thuc GL *************************/
				
				/******************** Bat dau Phan he *************************/
				/********** DD A_1**************/
				/*document.getElementById('CIFTYPE'+number).value = '';
				document.getElementById('TYPE'+number).value = '';
				document.getElementById('CURORINT'+number).value = '';
				document.getElementById('FRMTERMCD'+number).value = '';
				document.getElementById('FRMTERM'+number).value = '';
				document.getElementById('TOTERMCD'+number).value = '';
				document.getElementById('TOTERM'+number).value = '';*/
				
				/********** FD B_1**************/
				document.getElementById('FDTYPE'+number).value = '';
				
				/********** LN C_1**************/
				document.getElementById('FRMODSTAT'+number).value = '';
				document.getElementById('TOODSTAT'+number).value = '';
				document.getElementById('SECSTATUS'+number).value = '';
				document.getElementById('PPLN'+number).value = '';
				document.getElementById('CLLIST'+number).value = '';
				
				/********** TR D_5**************/
				/*document.getElementById('TRTERM'+number).value = '';
				document.getElementById('FDORLN'+number).value = '';
				document.getElementById('TRPRD'+number).value = '';*/
				
				/********** TF E_1**************/
				document.getElementById('PRDGRP'+number).value = '';
				document.getElementById('PRDCODE'+number).value = '';
				break ;
			}
			case "E_"+number:{ 
				/******************** Bat dau GL *************************/
				//document.getElementById('SBVORBTS'+number).value = '';
				//document.getElementById('CURORAMT'+number).value = '';
				//document.getElementById('AMTTYPE'+number).value = '';
				/******************** ket thuc GL *************************/
				
				/******************** Bat dau Phan he *************************/
				/********** DD A_1**************/
				/*document.getElementById('CIFTYPE'+number).value = '';
				document.getElementById('TYPE'+number).value = '';
				document.getElementById('CURORINT'+number).value = '';
				document.getElementById('FRMTERMCD'+number).value = '';
				document.getElementById('FRMTERM'+number).value = '';
				document.getElementById('TOTERMCD'+number).value = '';
				document.getElementById('TOTERM'+number).value = '';*/
				
				/********** FD B_1**************/
				document.getElementById('FDTYPE'+number).value = '';
				
				/********** LN C_1**************/
				document.getElementById('FRMODSTAT'+number).value = '';
				document.getElementById('TOODSTAT'+number).value = '';
				document.getElementById('SECSTATUS'+number).value = '';
				document.getElementById('PPLN'+number).value = '';
				document.getElementById('CLLIST'+number).value = '';
				
				/********** TR D_5**************/
				document.getElementById('TRTERM'+number).value = '';
				document.getElementById('FDORLN'+number).value = '';
				document.getElementById('TRPRD'+number).value = '';
				
				/********** TF E_1**************/
				/*document.getElementById('PRDGRP'+number).value = '';
				document.getElementById('PRDCODE'+number).value = '';*/
				break ;
			}
			default:{
				/******************** Bat dau GL *************************/
				//document.getElementById('SBVORBTS'+number).value = '';
				//document.getElementById('CURORAMT'+number).value = '';
				//document.getElementById('AMTTYPE'+number).value = '';
				/******************** ket thuc GL *************************/
				
				/******************** Bat dau Phan he *************************/
				/********** DD A_1**************/
				/*document.getElementById('CIFTYPE'+number).value = '';
				document.getElementById('TYPE'+number).value = '';
				document.getElementById('CURORINT'+number).value = '';
				document.getElementById('FRMTERMCD'+number).value = '';
				document.getElementById('FRMTERM'+number).value = '';
				document.getElementById('TOTERMCD'+number).value = '';
				document.getElementById('TOTERM'+number).value = '';*/
				
				/********** FD B_1**************/
				document.getElementById('FDTYPE'+number).value = '';
				
				/********** LN C_1**************/
				document.getElementById('FRMODSTAT'+number).value = '';
				document.getElementById('TOODSTAT'+number).value = '';
				document.getElementById('SECSTATUS'+number).value = '';
				document.getElementById('PPLN'+number).value = '';
				document.getElementById('CLLIST'+number).value = '';
				
				/********** TR D_5**************/
				document.getElementById('TRTERM'+number).value = '';
				document.getElementById('FDORLN'+number).value = '';
				document.getElementById('TRPRD'+number).value = '';
				
				/********** TF E_1**************/
				document.getElementById('PRDGRP'+number).value = '';
				document.getElementById('PRDCODE'+number).value = '';
				break;
			}
	  	}	
	}
	
	function selectcombo_soduhayphatsinh(number){
		var vboo = document.getElementById('CURORAMT'+number).value;
		//alert(vboo);
		if(vboo=='DCN' || vboo=='DCC' || vboo==''){
			document.getElementById('AMTTYPE'+number).disabled = true;
			document.getElementById('AMTTYPE'+number).value = '';
		}else{
			//alert('99');
			document.getElementById('AMTTYPE'+number).disabled = false;
		}
	}